<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin:0;
            padding:0;
        }
        body{
            height:3000px;
        }
        #box{
            height:100px;
            width:100px;
            margin-top:1000px;
            background-color: red;
        }
    </style>
</head>
<body>
    <div id="box"></div>
    <script>
        //2
        // scrollTop 返回文档的滚动top方向的距离（当窗口发生滚动时值改变）
        // scrollLeft 返回文档的滚动left方向的距离（当窗口发生滚动时值改变）

        let html=document.documentElement||document.body;
        console.log(html.scrollTop);
    </script>
</body>
</html>